package com.zzyl.controller.manager.nursing;

import com.fasterxml.jackson.databind.util.BeanUtil;
import com.github.pagehelper.Page;
import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelPageQueryDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.entity.nursing.NursingPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "护理计划表")
@RestController
@RequestMapping("/nursing/plan")
@RequiredArgsConstructor
public class NursingPlanController {
    private final NursingPlanService nursingPlanService;
    @GetMapping
    @ApiOperation("查询所有护理项目")
    public ResponseResult getNursingPlanlist(){
        NursingPlan nursingPlanVo = nursingPlanService.getNursingPlanlist();
        return ResponseResult.success(nursingPlanVo);
    }
    @PostMapping
    @ApiOperation("新增")
    public ResponseResult InstallNursingPlan(@Validated NursingPlanDto nursingPlanDto){
        nursingPlanService.InstallNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }
    @GetMapping("/search")
    @ApiOperation("分页")
    public ResponseResult selectsNationList(Integer pageNum, Integer pageSize, @RequestParam(required = false) String name,@RequestParam(required = false) Integer status){
        PageBean<NursingPlanVo> list = nursingPlanService.selectsNationList( pageNum,  pageSize,  name,  status);
        return ResponseResult.success(list);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult cxidNationList(@PathVariable Integer id){

        NursingPlan nursingPlanVo = nursingPlanService.cxidNationList(id);
        
        return ResponseResult.success(nursingPlanVo);
    }
    @PutMapping
    @ApiOperation("修改")
    public ResponseResult updataNationList(@RequestBody NursingPlanDto nursingPlanDto){

        nursingPlanService.updataNationList(nursingPlanDto);

        return ResponseResult.success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public ResponseResult DeleteNationList(@PathVariable Integer id){

        nursingPlanService.DeleteNationList(id);

        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult updatenursingStatus(@PathVariable Integer id ,@PathVariable Integer status){
        nursingPlanService.updatenursingStatus(id,status);
        return ResponseResult.success();
    }
}